package com.lfy.domian;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.stereotype.Component;

@Component
public class FactoryUtil implements BeanFactoryPostProcessor {

    private static ConfigurableListableBeanFactory configurableListableBeanFactory;
    @Override
    public void postProcessBeanFactory(ConfigurableListableBeanFactory configurableListableBeanFactory) throws BeansException {
        FactoryUtil.configurableListableBeanFactory = configurableListableBeanFactory;
    }
    public static <T>T getBean(Class<T> clazz){
        return configurableListableBeanFactory.getBean(clazz);
    }
}
